//
//  ViewController.swift
//  AccountingHelper
//
//  Created by HuangZe on 2025/5/18.
//

import UIKit

class MainViewController: TabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        setupTabs()
    }
    
    func setupTabs() {
        //扫码视图控制器
        let scanVC = ScanViewController()
        scanVC.title = "扫码"  // 添加导航栏标题
        scanVC.tabBarItem = UITabBarItem(
            title: "扫码",
            image: UIImage(systemName: "qrcode.viewfinder"),
            tag: 0
        )
        
        // 历史记录视图控制器
        let historyVC = HistoryViewController()
        historyVC.view.backgroundColor = .yellow
        historyVC.title = "历史记录"
        historyVC.tabBarItem = UITabBarItem(
            title: "历史",
            image: UIImage(systemName: "clock"),
            tag: 1
        )
        
        // 设置视图控制器
        let settingsVC = SettingsViewController()
        settingsVC.view.backgroundColor = .blue
        settingsVC.title = "设置"  // 添加导航栏标题
        settingsVC.tabBarItem = UITabBarItem(
            title: "设置",
            image: UIImage(systemName: "gear"),
            tag: 2
        )
        
        // 设置导航控制器
        let scanNavVC = NavigationController(rootViewController: scanVC)
        let settingsNavVC = NavigationController(rootViewController: settingsVC)
        let historyNavVC = NavigationController(rootViewController: historyVC)
        
        // 设置tabBar外观
        tabBar.tintColor = .systemBlue
        tabBar.unselectedItemTintColor = .gray
        
        viewControllers = [scanNavVC,historyNavVC,settingsNavVC]
    }
}
